Skip to content

fix: Use typed GCController properties for macOS system button mapping#96

Open
gnarhard wants to merge 7 commits intoflame-engine:mainfrom
gnarhard:fix/macos-dualsense-mapping
Open

fix: Use typed GCController properties for macOS system button mapping#96
gnarhard wants to merge 7 commits intoflame-engine:mainfrom
gnarhard:fix/macos-dualsense-mapping

Conversation

@gnarhard
Copy link
Copy Markdown

@gnarhard gnarhard commented Apr 2, 2026

Summary

On macOS, the DualSense (PS5) controller's Options button incorrectly maps to
GamepadButton.back instead of GamepadButton.start, and the touchpad click
is silently dropped.

The root cause is that the macOS native plugin identifies buttons by
GCControllerElement.sfSymbolsName, which is ambiguous across controller
types — both DualSense system buttons report capsule.portrait, making them
indistinguishable. The iOS plugin already avoids this by using typed
GCExtendedGamepad properties (gamepad.buttonMenu, gamepad.buttonOptions)
with fixed key names.

This PR aligns the macOS plugin with the iOS approach for system buttons and
adds touchpad click support.

Changes

gamepads_darwin (Swift)

  • Added getFixedKey() that matches elements against typed GCExtendedGamepad
    properties (buttonMenu, buttonOptions, buttonHome) and
    GCDualSenseGamepad/GCDualShockGamepad touchpadButton, returning
    unambiguous key names. Falls back to SF Symbol names for all other elements.

gamepads (Dart)

  • Added GamepadButton.touchpad enum variant.
  • Added fixed key mappings to MacosMapping: buttonMenustart,
    buttonOptionsback, buttonHomehome,
    touchpadButtontouchpad.
  • Added tests for the new mappings.

Raw event log (before fix)

Options button — expected: start, got: back
GamepadButton.back = 1.0 (raw: capsule.portrait 1.0)

Touchpad click — unmapped, silently dropped
[unmapped] button: plus.rectangle = 1.0

Test plan

  • melos run analyze — zero issues across all 9 packages
  • flutter test — all 79 tests pass (including new mapping tests)
  • flutter build macos — Swift compiles cleanly
  • Verified with physical DualSense controller on macOS 16 (Darwin 25.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants